package com.company.calendar.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.calendar.entity.HolidayType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 节假日类型Mapper接口
 * 
 * @author System
 * @since 1.0.0
 */
@Mapper
public interface HolidayTypeMapper extends BaseMapper<HolidayType> {
    
    /**
     * 查找所有未删除的类型
     */
    @Select("SELECT * FROM holiday_types WHERE is_deleted = 0")
    List<HolidayType> findByIsDeletedFalse();
    
    /**
     * 根据类型编码查找
     */
    @Select("SELECT * FROM holiday_types WHERE type_code = #{typeCode} AND is_deleted = 0")
    HolidayType findByTypeCodeAndIsDeletedFalse(@Param("typeCode") String typeCode);
    
    /**
     * 检查类型编码是否存在
     */
    @Select("SELECT COUNT(*) FROM holiday_types WHERE type_code = #{typeCode} AND is_deleted = 0")
    int existsByTypeCodeAndIsDeletedFalse(@Param("typeCode") String typeCode);
}
